package com.quanyan.stadium.service.gameRules;

import com.quanyan.stadium.api.req.ReqChallenge;
import com.quanyan.stadium.entity.TbGameEvent;
import com.quanyan.stadium.entity.TbGameEventTeam;
import com.quanyan.stadium.entity.TbGameRound;
import com.quanyan.stadium.entity.vo.*;

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;

/**
 * 根据赛制进行赛事编辑
 *
 * 版本:1.0
 * 状态:使用中
 *
 *
 */
public interface GameRoundService {

    /**
     * 根据赛事ID来创建赛事下的轮次
     *
     * @param
     * @return List<GameRound>
     * */
    List<GameRound> createGameRound(TbGameEvent tbGameEvent) throws Exception;

    /**
     * 生存相应的轮次数据
     *
     * @param
     * @return List<GameRound>
     * */
    List<TbGameRound> generateTbGameRound(TbGameEvent tbGameEvent, Integer roundNum, Integer roundNum1, Integer roundNum2, Integer currentTeams) throws Exception;

    /**
     *  根据人员信息生成对战表  ,
     *
     * */
    List<GameSchedule> generateCompList(ReqChallenge reqChallenge) throws Exception;


    /**
     * 校验对战表生成,逻辑 int 0表示正常
     *
     * */
    int validateCreateTbGameScheduleParam(List<TbGameRound> tbGameRoundList, List<TbGameEventTeam> tbGameEventTeamList, ReqChallenge reqChallenge,
                                          Integer preGameRoundId, TbGameRound currentTbGameRound, TbGameEvent tbGameEvent);
    /**
     * 开始创建对战表
     *
     * */
    List<VDefinedGameSchedule> startCreateTbGameSchedule(ReqChallenge reqChallenge,  List<TbGameRound> tbGameRoundList, List<TbGameEventTeam> tbGameEventTeamList,
                                                                TbGameEvent tbGameEvent, Integer preGameRoundId) throws Exception;

    /**
     *  根据人员信息生成对战表  ,
     *
     * */
    List<VDefinedGameSchedule> generateScheduleAndUpdateRound(Integer type, List<GameGroup> gameGroups, Integer  currentGameRoundId, ReqChallenge reqChallenge);

    /**
     *  更新场地和时间
     *
     * */
    void updateScheduleTimeAndPlaceUnit(Integer  currentGameRoundId, ReqChallenge reqChallenge);

    /**
     * 用户区别晋级人数
     *
     * */
    List<GameSchedule> transferTbGameSchedule2GameSchedule(List<VDefinedGameSchedule> vDefinedGameSchedules, Integer teamType, TbGameRound curGameRound) throws InvocationTargetException, IllegalAccessException;

    /**
     * 混合赛制,分组数物理编排
     * 存在分组的赛事,获取分组数目和晋级数目,根据队伍数目
     *
     *
     * */
    List<GameGroupNumAndRankNum> getGroupNmAndRankNumByTeamNum(Integer teamNum);

    /**
     * 更新时间和场地信息,当处于循环赛对战一次性生成时
     *
     * */
    void updateTimeAndUnit(Integer curGameRoundId, ReqChallenge reqChallenge);

    /**
     *  根据人员信息生成对战表  ,
     *
     * */
    Map<Integer, List<GameSchedule>> generateCompListV2(ReqChallenge reqChallenge) throws Exception;

    /**
     * 存在双打逻辑混乱的问题,这里根据赛程id和队伍id映射出总的id
     *
     * */
    List<Integer> gameTeamIdTransferTeamIdNew(Integer gameScheduleId, List<Integer> oldTeamIds);

    /**
     * 存在双打逻辑混乱的问题,这里根据赛程id和队伍id映射出总的id
     *
     * */
    Map<Integer, Integer> gameTeamIdTransferTeamIdNew(Integer gameEventId);
}
